package com.li.general.misc
{
import flash.display.Sprite;
import flash.events.Event;

public class StageInitSprite extends Sprite
{
    public function StageInitSprite()
    {
        super();
        addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
    }

    protected function onStageInit(w:Number, h:Number):void
    {
        // Override.
    }

    protected function onResize(w:Number, h:Number):void
    {
        // Override.
    }

    private function resizeHandler(evt:Event):void
    {
        onResize(stage.stageWidth, stage.stageHeight);
    }

    private function addedToStageHandler(evt:Event):void
    {
        removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
        stage.addEventListener(Event.RESIZE, resizeHandler);
        onStageInit(stage.stageWidth, stage.stageHeight);
    }
}
}